package demo.trueLicense;

import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * description: <br>
 * createTime: 2020/12/31 14:17 <br>
 *
 * @author zzh
 */
//#License相关配置
//        license:
//        subject: ioserver #主题
//        publicAlias: publicCert #公钥别称
//        storePass: a123456 #访问公钥的密码
//        licensePath: D:\licenseTest\license.lic #license位置
//        publicKeysStorePath: D:\licenseTest\publicCerts.keystore #公钥位置
@Configuration
@AllArgsConstructor
public class LicenseConfig {

    /**
     * 证书subject
     */
    @Value("${license.subject}")
    private String subject;

    /**
     * 公钥别称
     */
    @Value("${license.publicAlias}")
    private String publicAlias;

    /**
     * 访问公钥库的密码
     */
    @Value("${license.storePass}")
    private String storePass;

    /**
     * 证书生成路径
     */
    @Value("${license.licensePath}")
    private String licensePath;

    /**
     * 密钥库存储路径
     */
    @Value("${license.publicKeysStorePath}")
    private String publicKeysStorePath;

    @Bean(initMethod = "installLicense", destroyMethod = "unInstallLicense")
    public LicenseVerify licenseVerify() {
        return new LicenseVerify(subject, publicAlias, storePass, licensePath, publicKeysStorePath);
    }

}
